/*
*	ID : pallab81
* 	PROG : 10199
* 	LANG : C++
* 	2011-10-04-15.05.12 Tuesday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
int N,E;
map< string, int > id;
string revid[ 105 ];
int vis[105];
int dfn[105];
int low[105];
int itr;
int K=1;
vector< VI >edge;
set<string> point;
inline void ini(){
    id.clear();
    SET(vis,0);
    SET(dfn,0);
    SET(low,0);
    edge.assign( N+5, VI() );
    point.clear();
    itr=1;
}
inline void Read(){
    ini();
    string name;
    fo(i,N){
        cin>>name;
        id[name]=i+1;
        revid[i+1]=name;
    }
    CI(E);
    string s1,s2;
    fo(i,E){
        cin>>s1>>s2;
        int u = id[s1];
        int v = id[s2];
        edge[u].pb(v);
        edge[v].pb(u);
    }

}
inline void dfs(int u, int p=-1){
    vis[u]=1;
    low[u]=dfn[u]=itr;
    ++itr;
    int son=0;
    for(int i=0,j=SZ(edge[u]); i<j; ++i ){
        int v = edge[u][i];
        if( v==p )continue;

        if( vis[v]==1 ){
            dfn[u] = min( dfn[u], low[v] );
        }
        else{
            dfs(v,u);
            dfn[u] = min( dfn[u], dfn[v] );
            if( dfn[v] >= low[u] && p!=-1 ){
                point.insert( revid[u] );
            }
            ++son;
        }
    }
    if(p==-1 && son>1){
        point.insert( revid[u] );
    }
}
inline void Proc(){
    foE(i,1,N){
        if( vis[i]==0 )
            dfs(i);
    }
    int sz = SZ(point);
    if(K!=1){ printf("\n"); }
    printf("City map #%d: %d camera(s) found\n",K,sz);
    foit(it,point){
        printf("%s\n",  (*it) .c_str() );
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in", "rt", stdin);
    freopen("out", "wt", stdout);
#endif
    while( scanf("%d",&N)==1 ){
        if( N==0 )break;
        Read();
        Proc();
        ++K;
    }


    return 0;
}
